package com.saint.utils {
	
	public class Logger{
		
		public static const INFO:uint = 0;
		public static const DEBUG:uint = 2;
		public static const ERROR:uint = 4;
		public static const CRITICAL:uint = 6;
		public static const STEALTH_MODE:uint = 99;
		private static var logLevel:uint = 4;
		
		public static const INCLUSIVE:uint = 0;
		public static const EXCLUSIVE:uint = 1;
		private static var scope:uint = 0;
		
		public function Logger():void {
		}
		
		public static function setLogLevel(level:uint):void{
			logLevel = level;
			info("Logger setLogLevel: " + logLevelToString());
		}
		
		public static function setScope(level:uint):void {
			scope = level;
			info("Logger setScope: " + scopeToString());
		}
		
		/**
		 * INFO
		 * @param	message
		 */
		public static function info(message:String):void{
			if (logLevel <= Logger.INFO){
				trace(":info: " + message);
			}
		}
		
		/**
		 * DEBUG
		 * @param	message
		 */
		public static function debug(message:String):void{
			if (logLevel <= Logger.DEBUG){
				trace(":debug: " + message);
			}
		}
		
		/**
		 * ERROR
		 * @param	message
		 */
		public static function error(message:String):void{
			if (logLevel <= Logger.ERROR){
				trace(":error: " + message);
			}
		}
		
		/**
		 * CRITICAL
		 * @param	message
		 */
		public static function critical(message:String):void{
			if (logLevel <= Logger.CRITICAL){
				trace(":critical: " + message);
			}
		}
		
		/**
		 * internal utility
		 * @return log level as string
		 */
		private static function logLevelToString():String{
			var logString:String;
			switch (logLevel){
				case 0:
					logString = "INFO";
					break;
				case 2:
					logString = "DEBUG";
					break;
				case 4:
					logString = "ERROR";
					break;
				case 6:
					logString = "CRITICAL";
					break;
				case 99:
					logString = "STEALTH_MODE";
					break;
				default:
					trace(":unknown or custom log level: " + logLevel);
			}
			return logString;
		}
		
		/**
		 * internal utility
		 * @return scope level as string
		 */
		private static function scopeToString():String {
			var scopeString:String;
			switch (scope) {
				case 0:
					scopeString = "INCLUSIVE";
					break;
				case 1:
					scopeString = "EXCLUSIVE";
					break;
				default:
					trace(":unknown scope level: " + scope);
			}
			return scopeString;
		}
	}

}